#include "EventSet.h"

EventSet::EventSet(void)
{
}

EventSet::~EventSet(void)
{
}

Event* EventSet::addEvent(EventType t)
{
	Event* v = new Event(t);
	m_events.insert(std::make_pair(t,v));
	return v;
}

void EventSet::removeEvent(EventType t)
{
	EventContainer::iterator it = m_events.find(t);
	if (it != m_events.end())
	{
		m_events.erase(it);
	}
}

Event* EventSet::getEvent(EventType t)
{
	Event* v = findEvent(t);
	if (v)
		return v;

	return addEvent(t);
}

Event* EventSet::findEvent(EventType t)
{
	EventContainer::iterator it = m_events.find(t);
	if (it != m_events.end())
	{
		return it->second;
	}

	return NULL;
}

void EventSet::fireEvent(EventType t, EventParams& ep)
{
	Event* et = findEvent(t);
	if (et)
	{
		(*et)(ep);
	}
}